package com.molin.variableParameterTest;

public class Demo1 {
    //定义一个方法返回N个数的和
    public static void main(String[] args) {
        int sum=getSum(1,3,4,5);
        System.out.println(sum);
    }

    private static int getSum(int... arr) {
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }
}
